#pragma once
#include<iostream>
#include<unistd.h>
#include<string>
const static int defaultresult=0;
enum
{
    ok=1,
    div_zero,
    mod_zero,
    unknow
};
const std::string opers="+-*/%)(&";

class Task
{
    public:
    Task() {}
    Task(int x,int y,char op)
    :data_x(x)
    ,data_y(y)
    ,oper(op)
    ,result(defaultresult)
    ,code(ok)
    {

    }
    void Run()
    {
        switch(oper)
        {
            case '+':
            result=data_x+data_y;
            break;
            case '-':
            result=data_x-data_y;
            break;
            case '*':
            result=data_x*data_y;
            break;
            case '/':
            {
                if(data_y==0)
                {
                    code=div_zero;
                }
                else result=data_x/data_y;
            }
            break;
            case '%':
            {
                if(data_y==0)
                {
                    code=mod_zero;
                }
                else result=data_x%data_y;
            }
            break;
            default:
            code=unknow;
            break;
        }
    }
    void operator()()
    {
        Run();
        sleep(2);
    }
        std::string PrintTask()
    {
        std::string s;
        s = std::to_string(data_x);
        s += oper;
        s += std::to_string(data_y);
        s += "=?";

        return s;
    }
    std::string PrintResult()
    {
        std::string s;
        s = std::to_string(data_x);
        s += oper;
        s += std::to_string(data_y);
        s += "=";
        s += std::to_string(result);
        s += " [";
        s += std::to_string(code);
        s += "]";

        return s;
    }
    ~Task()
    {
    }

    private:
    int data_x;
    int data_y;
    char oper;
    int result;
    int code;
};